package cn.com.nes.site.service.crm.opportunity;

import cn.com.nes.mybatis.agent.crm.entity.Opportunity;
import cn.com.nes.site.controller.crm.opportunity.vo.ExportTemplateExcelOfEndCustomerVO;
import cn.com.nes.site.entity.em.crm.opportunity.OpportunityStageEnum;
import cn.com.nes.site.entity.iot.CascadeCell;
import cn.com.nes.site.service.crm.customer.bo.CustomerOpportunityBo;
import cn.com.nes.site.service.crm.opportunity.bo.GetOpportunityDetailBO;
import cn.com.nes.site.service.crm.opportunity.bo.OpportunityBO;
import cn.com.nes.site.service.crm.opportunity.bo.QueryOpportunityBO;
import cn.com.nes.site.service.crm.opportunity.bo.QueryOpportunityPageBO;
import cn.com.nes.site.service.crm.opportunity.dto.OpportunityAndContractDTO;
import cn.com.nes.site.service.crm.opportunity.dto.OpportunityDTO;
import cn.com.nes.site.service.crm.opportunity.dto.OpportunityInfoDto;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.Date;
import java.util.List;

/**
 * CrmOpportunityService 接口提供了对商机（Opportunity）对象的各种操作方法，包括保存、查询、删除等。
 * 该接口扩展了 IService<Opportunity> 接口，确保了基本的 CRUD 操作支持。
 */
public interface CrmOpportunityService extends IService<Opportunity> {

    void handleOpportunityStage(String opportunityUuid, OpportunityStageEnum opportunityStageEnum, Long operateUserId,
            Date operateDate, String operateCompanyId, String operateUserName) throws Exception;


    Opportunity getOpportunity(String opportunityUUid);


    /**
     * 查询商机列表
     */
    List<Opportunity> getOpportunities(QueryOpportunityBO queryOpportunityBo) throws Exception;


    /**
     * 查询商机列表，包含合同信息
     * @param queryOpportunityBo 查询商机业务模型
     * @return
     */
    List<OpportunityAndContractDTO> getOpportunitiesContainContract(
            QueryOpportunityBO queryOpportunityBo) throws Exception;


    List<OpportunityDTO> getCustomerOpportunityList(CustomerOpportunityBo customerOpportunityBo);


    /**
     * 根据商机id查询商机详情
     * @param uuid
     * @return
     */
    Opportunity getOpportunityDetailByUuid(String uuid) throws Exception;


    /**
     * 删除商机
     * @param deletedCustomerIds 客户ID列表
     * @param operateUserId      操作人ID
     * @param operateDate        操作时间
     */
    void deleteByCustomerIds(List<String> deletedCustomerIds, Long operateUserId, Date operateDate) throws Exception;


    Opportunity getOpportunity(String customerUuid, String opportunityUuid);


    /**
     * 商机成交
     * @param opportunityBO
     * @return
     */
    void opportunitySuccess(OpportunityBO opportunityBO) throws Exception;


    /**
     * 商机列表分页查询
     * @param queryOpportunityPageBO
     * @return
     */
    Page<OpportunityInfoDto> getOpportunityPage(QueryOpportunityPageBO queryOpportunityPageBO) throws Exception;


    /**
     * @param bo
     * @return
     */
    OpportunityInfoDto getOpportunityBaseInfo(GetOpportunityDetailBO bo) throws Exception;


    /**
     * 导出终端客户模版
     * @param vo
     * @return
     */
    List<CascadeCell> getEndCustomerSaleTemplateExcelHeaderCellContent(
            ExportTemplateExcelOfEndCustomerVO vo) throws Exception;


    /**
     * 获取 EXCEL 表头
     * @param opportunityUuid
     * @return
     */
    List<List<String>> getEndCustomerSaleTemplateExcelHeaders(String opportunityUuid) throws Exception;


    Opportunity getOpportunityByName(String customerUuid, String opportunityName) throws Exception;


    List<String> getCoverageArea(String opportunityUuid) throws Exception;


    List<String> getSettingDeviceModels(String opportunityUuid) throws Exception;

    /**
     * 根据安装工单id查询商机详情
     */
    OpportunityInfoDto getOpportunityDetailByWorkOrderId(Long workOrderId);
}
